package cn.stylefeng.guns.czlm.mapper;

import cn.stylefeng.guns.czlm.entity.TbProduct;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/***
 * 商品表d的接口
 */
public interface TbProductMapper extends BaseMapper<TbProduct> {
    /***  * 查询全部* @return*/
    Page<Map<String, Object>> listProductByMap(@Param("page") Page page, @Param("tbProduct") TbProduct tbProduct);
    /*** 上下架* @param tbProduct* @return*/
      @Update("update tb_product set isMarketable=#{isMarketable} where id=#{id}")
       boolean ModifyIsMarketable(TbProduct tbProduct);
    /*** 首推* @param tbProduct* @return*/
    @Update("update tb_product set isRecommend=#{isRecommend} where id=#{id}")
    boolean ModifyIsRecommend(TbProduct tbProduct);

    /***
     * 按id差全部
     * @param id
     * @return
     */
    @Select("select  id, createDate, modifyDate, name, caption, thumbnail,\n" +
            "         productCategoryId, sn, sales, isMarketable, price,\n" +
            "        marketPrice, stock, parameterValue, sort_num, isRecommend, active from tb_product where id = #{id}")
    TbProduct tbProductById(Integer id);

    @Select("select thumbnail from tb_product")
    List<String> listThumbnail();//查询全部图片

       void  ModifySave(TbProduct tbProduct);//保存

    void insertTbProduct(TbProduct tbProduct);//新增
}
